Passed
Pull Request — master (#146)
by Mathieu
02:09
created

Project.update   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { Customer } from '../Customer/Customer.entity';
3
4
@Entity()
5
export class Project {
6
  @PrimaryGeneratedColumn('uuid')
7
  private id: string;
8
9
  @Column({type: 'varchar', nullable: false})
10
  private name: string;
11
12
  @Column({type: 'integer', nullable: false, default: 7})
13
  private dayDuration: number;
14
15
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
16
  private createdAt: Date;
17
18
  @ManyToOne(type => Customer, {nullable: false})
19
  private customer: Customer;
20
21
  constructor(name: string, dayDuration: number, customer: Customer) {
22
    this.name = name;
23
    this.dayDuration = dayDuration;
24
    this.customer = customer;
25
  }
26
27
  public getId(): string {
28
    return this.id;
29
  }
30
31
  public getName(): string {
32
    return this.name;
33
  }
34
35
  public getDayDuration(): number
36
  {
37
    return this.dayDuration;
38
  }
39
40
  public getCreatedAt(): Date {
41
    return this.createdAt;
42
  }
43
44
  public getCustomer(): Customer {
45
    return this.customer;
46
  }
47
48
  public getFullName(): string {
49
    return `[${this.customer.getName()}] ${this.getName()}`;
50
  }
51
52
  public update(customer: Customer, dayDuration: number, name: string): void {
53
    this.customer = customer;
54
    this.dayDuration = dayDuration;
55
    this.name = name;
56
  }
57
}
58